package homework1;

import java.util.ArrayList;
import java.util.Iterator;

public class Test {
    public static void main(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        list.add(100);
        list.add(200);
        list.add(300);
        list.add(400);
        list.add(500);
        //自增for
        for (int i = 0; i < list.size(); i++) {
            Integer num = list.get(i);
            int i1 = num.intValue();
            System.out.println(i1);
        }

        //增强for
        for (Integer integer : list) {
            System.out.println("integer = " + integer);
        }

        //使用迭代器遍历
        Iterator<Integer> iterator = list.iterator();
        //结合while循环进行遍历
        while (iterator.hasNext()){
            Integer next = iterator.next();
            System.out.println("next = " + next);
        }
    }
}
